package br.com.eji.database;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class SqlServerConnection {
	String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
	//String driverName = "com.sqlserver.jdbc.SQLServerDriver";
	//String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
	Connection con = null;
	
	public SqlServerConnection() { 
		try {
			//Loading Driver for MySql
			Class.forName(driverName); 
		} catch (ClassNotFoundException e) {
			System.out.println("ERRO COM O NOME DO DRIVER:  " + e.toString());
		}
	}
	
	public Connection createConnectionProLuxDBOpr() {
		System.out.println("ENTROU XXXXXXXXXXXXXXXXX");
		try {
			//String connectionUrl= "jdbc:sqlserver://{computer-name}\\SQLEXPRESS:1433;databaseName=abc;integratedSecurity=true;","sa","password";
			String connectionUrl="jdbc:sqlserver://192.168.46.61\\opr;databaseName=ProluxDBOpr;";
			//String connectionUrl="jdbc:sqlserver://192.168.46.61;databaseName=ProluxDBOpr;instanceName=opr;integratedSecurity=true;";
			String userName="selenium";
			String userPass="selenium123";
			
			con = DriverManager.getConnection(connectionUrl,userName,userPass);
			System.out.println("******* Connection created successfully........");
		} catch (SQLException e) {
			System.out.println("ERRO NA STRING DE CONEXÃO: " + e.toString());
		}
		return con;
	}
	
	public void closeConnection(){
		try{
			this.con.close();
		System.out.println("******* Connection closed Successfully.........");
		}catch(Exception e){
			System.out.println(e.toString());
		}
	}
//------------------------------------------------------TABELAS TEMPORARIAS------------------------------------------------------------	
		
	
}

